package general.zjitc.net.androidjgeneral2;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * @author 朱志文
 * @data 2019/11/17 0017
 */
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.MyViewHolder> {
    private List<Integer> mContent;
    private Context mContext;

    public RecyclerViewAdapter(List<Integer> mContent, Context mContext) {
        this.mContent = mContent;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view=LayoutInflater.from(mContext).inflate(R.layout.recycler,viewGroup,false);
        MyViewHolder myViewHolder=new MyViewHolder(view);
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {
        myViewHolder.image_bizhi.setImageResource(mContent.get(i));
    }

    @Override
    public int getItemCount() {
        return mContent.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView image_bizhi;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            image_bizhi=itemView.findViewById(R.id.image_bizhi);
        }
    }
}
